// SettingDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Bloodlead.h"
#include "SettingDlg.h"

#include "EnumSerial.h"
// CSettingDlg dialog

IMPLEMENT_DYNAMIC(CSettingDlg, CDialog)

CSettingDlg::CSettingDlg( CONST SSerInfo *Info, CONST COMMCONFIG *Config, UINT nCount, CWnd* pParent /*=NULL*/)
	: CDialog(CSettingDlg::IDD, pParent)
	, mInfo( Info )
	, mConfig( Config )
	, mCount( nCount )
	, mSamplingSeconds(10)
	, mInvaintSeconds(5)
{
	
}

CSettingDlg::~CSettingDlg()
{
}

void CSettingDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_COMBO_COM, mComboCtrl);
	DDX_Text(pDX, IDC_EDIT_SAMPLING_SECONDS, mSamplingSeconds);
	DDX_Text(pDX, IDC_EDIT_INVAINT_SECONDS, mInvaintSeconds);
}


BEGIN_MESSAGE_MAP(CSettingDlg, CDialog)
END_MESSAGE_MAP()


// CSettingDlg message handlers

BOOL CSettingDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  Add extra initialization here
	for( INT i = 0; i < mCount; ++i )
	{
		INT item = mComboCtrl.AddString( mInfo[i].strFriendlyName.c_str() );
		if( item != -1 )
			mComboCtrl.SetItemData( item, i );
	}

	if( mComboCtrl.GetCount() )
		mComboCtrl.SetCurSel(0);

	mComboCtrl.SetFocus();
	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}

void CSettingDlg::OnOK()
{
	// TODO: Add your specialized code here and/or call the base class
	UpdateData( TRUE );
	int item = mComboCtrl.GetCurSel();
	if( item != -1 )
		mIndex = (INT)mComboCtrl.GetItemData(item);
	CDialog::OnOK();
}
